package com.sztz.mapstruct.M表达式;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * CarMapper
 *
 * @author yyf
 * @email yeyafei@hotmail.com
 */
@Mapper
public interface CarMapper {

    CarMapper INSTANCE = Mappers.getMapper(CarMapper.class);

    /**
     * 表达式
     *
     * @param car
     * @return CarDto
     */
    @Mappings({
            @Mapping(target = "owner", expression = "java( new Describe().owner( car.getOwner()) )"),
            @Mapping(target = "id", defaultExpression = "java( java.util.UUID.randomUUID().toString())")
    })
    CarDTO toDto(Car car);
}
